package com.whg.shiro.controller;

import com.whg.shiro.domain.RoleModel;
import com.whg.shiro.domain.UserModel;
import com.whg.shiro.domain.common.JsonData;
import org.apache.shiro.SecurityUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author whg
 * @create 2022/10/12 14:04
 * @description：
 */
@RestController
@RequestMapping("authc")
public class OrderController {

    @RequestMapping("/video/play_record")
    public JsonData play_record(){
        Map<String,String> recordMap = new HashMap<>();
        Object principal = SecurityUtils.getSubject().getPrincipal();
        if (principal instanceof RoleModel){
            recordMap.put("roleName", ((RoleModel) principal).getName());
        }
        if (principal instanceof UserModel){
            recordMap.put("username", ((UserModel) principal).getUsername());
        }

        recordMap.put("SpringBoot","1");
        recordMap.put("java","2");
        recordMap.put("linux","3");
        recordMap.put("rocketMq","4");

        return JsonData.buildSuccess(recordMap);
    }
}
